package com.mi.rof.config;


import com.mi.rof.engineer.entity.RepairOrderEvents;

import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;
import org.springframework.stereotype.Component;


/**
 * @author zwq
 *事件监听配置
 */
@Component
@WithStateMachine(name = RepairOrderStateMachineConfig.MACHINE_ID)
@Slf4j
public class RepairOrderEventConfig {
    private static final String ORDER_ID_HEADER = "orderId";


    @OnTransition(source = "ORDER_SUBMITTED",target = "ORDER_PENDING_CONFIRM")
    public void addMq(Message<RepairOrderEvents> message){
        log.info("状态变化：{}", message.getHeaders().get(ORDER_ID_HEADER));
    }

    @OnTransition(source = "ORDER_PENDING_CONFIRM",target = "CHECK_CONFIRM")
    public void uploadInfo(Message<RepairOrderEvents> message){

        log.info("状态：{}", message.getHeaders().get(ORDER_ID_HEADER));
    }



}
